package com.zheng.redpacket.server.utils.consumer;

import com.zheng.redpacket.server.dto.UserLoginDto;
import com.zheng.redpacket.server.serivce.SysLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Component
public class LoginConsumer {
    private static final Logger LOGGER = LoggerFactory.getLogger(LoginConsumer.class);
    @Autowired
    private SysLogService sysLogService;

    @RabbitListener(queues = "${mq.login.info.queue.name}", containerFactory = "singleListenerContainer")
    public void consumeMsg(@Payload UserLoginDto dto) {
        LOGGER.info("日志记录成功，{}", dto);
        sysLogService.recordLog(dto);
    }
}
